/***************************************************************************
 *   Copyright (C) 2008 by Rysiek Krol,,,   *
 *   rysiek@Babylon2   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#ifndef DISPLAYOPERATIONS_H
#define DISPLAYOPERATIONS_H

#include "picturemanager.h"
#include "Events/fileoperationerrorevent.h"
#include "filesoperations.h"

#include <QObject>
#include <QTimer>

class QFileInfo;


/**
	@author Rysiek Krol <rysiek.krol@gmail.com>
*/
class DisplayOperations : public QObject
{
    Q_OBJECT
public:
    DisplayOperations(PictureManager *manager);
    ~DisplayOperations();
    void setIsSlideShowActive(bool theValue);
    bool getIsSlideShowActive() const;
    void getPreviousSlide();
    void noSelectedFilesMessage();
    void rotateImage(int);
    void handleContextMenu(QContextMenuEvent *event);
    void clearSlideList();
    void handleFileOperationError(FileOperationErrorEvent *errorEvent);

public slots:
    void slideShowTimerTimeout();
    void slideShowSlot(FilesOperations::ActionSource source = FilesOperations::BrowserWidget);
    void slideShowTreeSlot();
    void searchSlot();
    void keywordsSlot();
    void rotateImage180();
    void rotateImage270();
    void rotateImage90();
    void displayNextImage();
    void displayPreviousImage();
    void displayCorrectImage();
    void itemSelectionChanged();
    void imagePropertiesSlot();

private:
    void displayNextImage(bool reloadLoader);
    PictureManager *manager;
    int displayOperationErrorDialog(FileOperationErrorEvent *errorEvent);
    //SlideShow methods
    QTimer *timer;
    QList<QFileInfo> *slideList;
    int slideIndex;
    void generateSlideShowFileList(FilesOperations::ActionSource source);
    void scrollToCurrentItem();
    QList<QFileInfo> generateSlideShowFileListFromDirectory(QDir dir);
    QFileInfo getNextSlide();
    void customEvent ( QEvent *event );
    bool isPictureLoaded;
    bool isSlideShowActive;
private slots:


};

#endif
